﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utils.MathUtilitys;
using Microsoft.Xna.Framework;

namespace Utils.Menu.Buttons
{
    public class RectButton : AbstractButton
    {
        FRect rect;

        public FRect Rect { get { return rect; } set { rect = value; } }
        public float Width { get { return rect.Width; } set { rect.Width = value; } }
        public float Height { get { return rect.Height; } set { rect.Height = value; } }

        public RectButton(ButtonListener listener, FRect rect)
            : base(listener)
        {
            this.rect = rect;
        }

        public override bool MouseInside(Vector2 mousePosition)
        {
            float widthHalf = rect.Width / 2f;
            float heightHalf = rect.Height / 2f;
            return mousePosition.X >= rect.X - widthHalf && mousePosition.X <= rect.X + widthHalf
                   && mousePosition.Y >= rect.Y - heightHalf && mousePosition.Y <= rect.Y + heightHalf;
        }
    }
}
